package com.com.itext.day1;

import com.itextpdf.io.font.FontConstants;
import com.itextpdf.io.font.PdfEncodings;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.List;
import com.itextpdf.layout.element.ListItem;
import com.itextpdf.layout.element.Paragraph;

//测试字体
public class demo2 {
    public static void main(String[] args) throws Exception {
        //可以编写的pdf文件
        PdfWriter writer = new PdfWriter("D:\\测试pdf\\day1_2.pdf");
        PdfDocument pdf = new PdfDocument(writer);
        Document document = new Document(pdf);
        //必须电脑里面有的字体
        //PdfFont font = PdfFontFactory.createFont("STSong-Light", "UniGB-UCS2-H",true);
        //可以使用tty文件
        PdfFont font = PdfFontFactory.createFont("C:/Windows/Fonts/simyou.ttf", PdfEncodings.IDENTITY_H,true);
        document.add(new Paragraph("测试字体：").setFont(font));
        /*List list = new List().setSymbolIndent(12).setListSymbol("\u2022").setFont(font);
        list.add(new ListItem("Never gonna give you up "))
                .add(new ListItem("Never gonna let "))
                .add(new ListItem("第三行"))
                .add(new ListItem("第四行"))
                .add(new ListItem("第五行"));
        document.add(list);*/
        document.close();
    }
}
